<template>
    <div>
        <el-card shadow="hover" :body-style="{padding: '0px'}">
            <div class="card-box clearfix">
                <i class="box-title-icon fontColor" :class="noticeContent.icon"></i>
                <template>
                    <el-tabs v-model="activeName" @tab-click="handleNoticeClick">
                        <el-tab-pane :label="noticeContent.name" name="first">
                            <div class="tabs-content-box">
                                <el-table :data="noticeList" :show-header="false" style="width: 100%;font-size:14px;">
                                    <el-table-column width="40">
                                        <template slot-scope="scope">
                                            <div class="todo-tag" v-bind:class="'todo-tag-'+(scope.$index+1)">{{scope.$index+1}}</div>
                                        </template>
                                    </el-table-column>
                                    <el-table-column show-overflow-tooltip>
                                        <template slot-scope="scope">
                                            <div class="todo-item">
                                                <a href="#" title="" @click="openMenuFunction2(scope.row.id)">{{scope.row.title}}</a>
                                            </div>
                                        </template>
                                    </el-table-column>
                                    <!--<el-table-column width="80">
                                        <template slot-scope="scope">
                                            <div class="todo-name">{{scope.row.original}}</div>
                                        </template>
                                    </el-table-column>-->
                                    <el-table-column width="102">
                                        <template slot-scope="scope">
                                            <div class="todo-date">{{scope.row.pubTime}}</div>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                        </el-tab-pane>
                    </el-tabs>
                </template>
                <el-button class="btn-more" type="text" >
                    <a href="#" title="" @click="handleNoticeMore" class="fontColor">MORE</a>
                </el-button>
            </div>
        </el-card>
    </div>
</template>

<script>
import { noticeContent } from './data/Content.js';
import bus from '../../common/bus';
import { formatDate } from '~/assets/utils/date.js';
export default {
    name: 'noticeList',

    data() {
        return {
            activeName: 'first',
            //noticeList: require("./data/NoticeData.json"),
            noticeList:[],
            noticeContent: noticeContent
        };
    },
    created:function (){
        this.getList();
    },
    methods: {
        getList(){
            this.$axios.get(noticeContent.noticeUrl)
                .then(res => {
                    this.noticeList = res.data.map( item => {
                        item['pubTime'] = formatDate(item['pubTime'], 'yyyy-MM-dd');
                        return item;
                    });

                });
        },
        openMenuFunction(id,title){
            //console.log(url,title);
            bus.$emit('openMenu','http://198.16.192.12/infopub/dispPub.action?pubid='+id+'/',title);
        },
        openMenuFunction2(id){
            window.open('http://198.16.192.12/infopub/dispPub.action?pubid=' + id, '_blank');
        },
        handleNoticeClick(tab, event) {
            console.log(tab, event);
        },
        handleNoticeMore(){
            // let menu = {
            //     url:noticeContent.moreUrl,
            //     name:noticeContent.name,
            // };
            // bus.$emit('openMenu',menu);
            // window.open(noticeContent.moreUrl,noticeContent.name);
            let obj=window.open(noticeContent.moreUrl);

            obj.document.title=noticeContent.name;
        }
    }
};
</script>

